package com.itheima.neibulei;

import java.util.Random;

public interface Demo8 {
    int getValues(String name);
}

class Te {
    public static void main(String[] args) {
        Demo8 d8 = new Demo8() {
            @Override
            public int getValues(String name) {
                Random ran = new Random();
                int r = ran.nextInt(10);
                System.out.println("参数" + name);
                return r;
            }
        };
        //匿名内部类实现
        System.out.println(d8.getValues("内部类hello........"));
        //函数式接口实现
        Demo8 dd = (String name) -> {
            Random ran = new Random();
            int r = ran.nextInt(10);
            System.out.println("参数" + name);
            return r;
        };
        System.out.println(dd.getValues("内部类world........."));

        get(new Demo8() {
            @Override
            public int getValues(String name) {
                Random ran = new Random();
                int r = ran.nextInt(10);
                System.out.println("参数" + name);
                return r;
            }
        }, "函数式编程hello...........");
        get((String name) -> {
            Random ran = new Random();
            int r = ran.nextInt(10);
            System.out.println("参数" + name);
            return r;
        }, "函数式编程world........");
    }

    public static void get(Demo8 d, String name) {
        System.out.println(d.getValues(name));
    }

}